package org.example.mybatis.controller;

import org.example.mybatis.domain.SmbmsBill;
import org.example.mybatis.mapper.SmbmsBillMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class MybatisController {

    @Autowired
    private SmbmsBillMapper smbmsBillMapper;

    //打印端口
    @Value("${server.port}")
    private String port;

    @GetMapping("/{id}")
    public SmbmsBill selectByPrimaryKey(@PathVariable("id") Long id) {
        System.out.println("调用了mybatis服务，端口为：" + port);
        return smbmsBillMapper.selectByPrimaryKey(id);
    }
}
